$(function(){
    for(var i=0;i<50;i++){
        $('.air-relative').find('.gray').append('<span></span>');
        $('.air-absolutely').find('.gray').append('<span></span>')
    }

    var pressureValRel=0;//初始气压(相对)
    var pressureValNowRel=32;//当前气压（相对）
    function airPreRel(now,old,par){
        if(now>old){
            par.find('.light').append('<span></span>');
            pressureValRel++;
        }else if(now<old){
            par.find('.light').children('span:last-child').remove();
            pressureValRel--;
        }else{
            clearInterval(pressureRunRel);
            return
        }
        $('.hpa-rel').text(pressureValRel*2);
    }
    var pressureRunRel=setInterval(function(){
        airPreRel(pressureValNowRel,pressureValRel,$('.air-relative'));
    },50);

    var pressureValAbs=0;//初始气压(绝对)
    var pressureValNowAbs=21;//当前气压（绝对）
    function airPreAbs(now,old,par){
        if(now>old){
            par.find('.light').append('<span></span>');
            pressureValAbs++;
        }else if(now<old){
            par.find('.light').children('span:last-child').remove();
            pressureValAbs--;
        }else{
            clearInterval(pressureRunAbs);
            return
        }
        $('.hpa-abs').text(pressureValAbs*2);
    }
    var pressureRunAbs=setInterval(function(){
        airPreAbs(pressureValNowAbs,pressureValAbs,$('.air-absolutely'));
    },50);
});
